package com.service.atf.reply.service;

import com.service.atf.base.model.Account;
import com.service.atf.base.model.TFCharge;
import com.service.atf.reply.ac.AccountManager;
import com.service.atf.reply.core.IReadExecutor;

import java.util.Map;

/**
 * User: luotao
 * Date: 12-3-21
 * Time: 17:00:00
 */
public class ChargeService2 implements IReadExecutor<TFCharge> {
    @Override
    public boolean isNotify() {
        return true;
    }

    private static final String KEY_BALC_CHARGE = "balcCharge";

    private static final String KEY_BALC_AWARD = "balcAward";

    public void initOut(Map out) {
        out.put(KEY_BALC_CHARGE, 0);
        out.put(KEY_BALC_AWARD, 0);
    }

    @Override
    public void execute(boolean recover, AccountManager accountManager, TFCharge charge, Map out) {
        // Validata.validataCustomerCode(this, charge.getCustomerCode());
        Account account = accountManager.getBussAccount(charge.getCustomerCode());
        //Validata.validataACNull(this, charge.getCustomerCode(), account);
        account.setBalcCharge(account.getBalcCharge() + charge.getChargeTradeMoney());
        accountManager.updateAccount(account);
        out.put(KEY_BALC_CHARGE, account.getBalcCharge());
        out.put(KEY_BALC_AWARD, account.getBalcAward());
    }
}
